<?php
/**
 * Created by PhpStorm.
 * User: tom_xia
 * Date: 2018/6/9
 * Time: 21:48
 * 查询视频状态
 */
require_once __DIR__."/login_filter.php";

use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\cls\tom\Tools;
use app\model\UserMaterial;

$userId = $Auth["user_id"];
if(empty($_GET["job_id"])){
    Response::output(-1,"参数错误");
}
$jobId = $_GET["job_id"];
if(!Tools::isLegalUUID($jobId)){
    Response::output(-1,"无效job_id-1");
}
$db = SysResource::getDB(false);
$userMaterialModel = new UserMaterial($db);
$info = $userMaterialModel->getInfo(["user_material_uuid"=>$jobId,"user_uuid"=>$Auth["user_uuid"]]);
if(empty($info)){
    Response::output(-1,"无效job_id-2");
}
Tools::apiLimit(["api"=>"query_video_status","id"=>$userId,"m"=>200]);
if($info["mix_status"] == 0){
    Response::output(0,"处理中^_^",["is_complete"=>0]);
} elseif($info["mix_status"] == 1 && !empty($info["music_video_url"])){
    Response::output(0,"处理完成^_^",["is_complete"=>1,"music_video_url"=>$info["music_video_url"]]);
}else{
    Response::output(0,"处理失败-_-",["is_complete"=>2]);
}